<?php

namespace So;

use Hyperf\Utils\ApplicationContext;
use Psr\SimpleCache\CacheInterface;

/**
 * 实现类方式的cache
 * 支持静态与非静态同时调用
 * @author Saopig <1306222220@qq.com>
 */
class Cache
{
    public static function instance()
    {
        return ApplicationContext::getContainer()->get(CacheInterface::class);
    }

    public static function __callStatic($name, $arguments)
    {
        return ApplicationContext::getContainer()->get(CacheInterface::class)->$name(...$arguments);
    }

    public function init()
    {
        return ApplicationContext::getContainer()->get(CacheInterface::class);
    }

    public function __call($name, $arguments)
    {
        return $this->init()->$name(...$arguments);
    }


}